<template>
  <div class="main">
    <div class="search">
      <el-form :inline="true" :model="search">
        <el-form-item>
          <el-button type="success" size="small" @click="resetReportForm(); dialogShow = true">添加</el-button>
        </el-form-item>
        <el-form-item label="用户姓名">
          <el-input v-model="search.adName" size="small" placeholder="用户名" clearable></el-input>
        </el-form-item>
        <el-form-item label="用户名">
          <el-input v-model="search.adUserName" size="small" placeholder="用户名" clearable></el-input>
        </el-form-item>
        <el-form-item label="联系电话">
          <el-input v-model="search.adPhone" size="small" placeholder="联系电话" clearable></el-input>
        </el-form-item>
        <!--        <el-form-item label="备注">-->
        <!--          <el-input v-model="search.description" size="small" placeholder="备注" clearable></el-input>-->
        <!--        </el-form-item>-->
        <el-form-item>
          <el-button type="info" size="small" @click="searchClick">查询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="list">
      <el-table
          :data="data"
          stripe
          style="width: 100%">
        <el-table-column prop="adName" label="用户姓名"></el-table-column>
        <el-table-column prop="adUserName" label="用户名"></el-table-column>
        <el-table-column prop="adPhone" label="联系电话"></el-table-column>
        <el-table-column prop="adStatus" label="状态">
          <template slot-scope="scope">
            {{ scope.row.adStatus == '1' ? '启用' : '禁用' }}
          </template>
        </el-table-column>
        <el-table-column prop="description" label="备注" show-overflow-tooltip></el-table-column>
        <el-table-column label="操作" width="170px">
          <template slot-scope="scope">
            <el-button type="primary" @click="reportForm = {...scope.row}; dialogShow = true">编辑</el-button>
            <el-button type="danger" @click="del(scope.row.adId)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
          @size-change="sizeChange"
          @current-change="currentChange"
          :current-page="pageNo"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
      </el-pagination>
    </div>
    <el-dialog
        :title="reportForm.id ? '修改' : '添加'"
        :visible.sync="dialogShow"
        width="600px"
        fullscreen
        @close="dialogClose"
    >
      <el-form ref="form" :model="reportForm" label-width="100px" :rules="rules">
        <el-row>
          <el-col :span="8">
            <el-form-item prop="productName" label="样品名称">
              <el-input type="text" placeholder="请输入样品名称" v-model="reportForm.productName"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="sampleType" label="样品型号">
              <el-input type="text" placeholder="请输入样品型号" v-model="reportForm.sampleType"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="sampleNum" label="样品数量">
              <el-input type="text" placeholder="请输入样品数量" v-model="reportForm.sampleNum"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="sampleBernum" label="样品编号">
              <el-input type="text" placeholder="请输入样品编号" v-model="reportForm.sampleBernum"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="producerName" label="生产者名称">
              <el-input type="text" placeholder="请输入生产者名称" v-model="reportForm.producerName"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="registeredAddress" label="注册地址">
              <el-input type="text" placeholder="请输入注册地址" v-model="reportForm.registeredAddress"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="manufactoryName" label="生产厂名称">
              <el-input type="text" placeholder="请输入生产厂名称" v-model="reportForm.manufactoryName"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="registeredAddressSample" label="样品注册地址">
              <el-input type="text" placeholder="请输入样品注册地址" v-model="reportForm.registeredAddressSample"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-date-picker
                v-model="reportForm.productionDate"
                type="date"
                placeholder="选择日期"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd">
            </el-date-picker>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="sampleAcqMethod" label="样品取得方式">
              <el-input type="text" placeholder="请输入样品取得方式" v-model="reportForm.sampleAcqMethod"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="registeredAddressSample" label="抽/供样日期">
              <el-input type="text" placeholder="请输入抽/供样日期" v-model="reportForm.samplingBasicDate"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="arriveDate" label="到样时间">
              <el-input type="text" placeholder="请输入到样时间" v-model="reportForm.arriveDate"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="sampleGrade" label="样品等级">
              <el-input type="text" placeholder="请输入样品等级" v-model="reportForm.sampleGrade"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="samplingBasicNumber" label="抽样基数">
              <el-input type="text" placeholder="请输入抽样基数" v-model="reportForm.samplingBasicNumber"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="samplingBasicPlace" label="抽/验样地点">
              <el-input type="text" placeholder="请输入抽/验样地点" v-model="reportForm.samplingBasicPlace"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="provingTime" label="检验时间">
              <el-input type="text" placeholder="请输入检验时间" v-model="reportForm.provingTime"/>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item prop="checkGroundPoint" label="检验地点">
              <el-input type="text" placeholder="请输入检验地点" v-model="reportForm.checkGroundPoint"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="mainTestingEquipment" label="检验依据">
              <el-input type="text" placeholder="请输入检验依据" v-model="reportForm.mainTestingEquipment"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkConclusion" label="检验结论">
              <el-input type="text" placeholder="请输入检验结论" v-model="reportForm.checkConclusion"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="remark" label="检验备注">
              <el-input type="text" placeholder="请输入备注" v-model="reportForm.remark"/>
            </el-form-item>
          </el-col>
        </el-row>
        <br/>
        <el-row>
          <el-col :span="8">
            <el-form-item prop="pictureProductName" label="样品照片">
              <el-upload
                  class="avatar-uploader"
                  style="border: 1px solid #d9d9d9; width: 100px; height: 100px"
                  :action="baseUrl + '/reportApproval/report/fileUplod'"
                  :headers="{'Authorization': getToken()}"
                  :show-file-list="false"
                  :on-success="handleAvatarSuccess"
                  :before-upload="beforeAvatarUpload">
                <img v-if="reportForm.pictureProductName" :src="reportForm.pictureProductName" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon" style="margin-left: 40px; margin-top: 40px;"></i>
              </el-upload>
              <!--              <el-input type="text" placeholder="请输入样品照片" v-model="reportForm.pictureProductName"/>-->
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="涵盖机型" label="样品图片">
              <el-input type="text" placeholder="请输入涵盖机型" v-model="reportForm.pictureModel"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="pictureProductName" label="样品照片">
              <el-input type="text" placeholder="请输入样品照片" v-model="reportForm.pictureProductName"/>
            </el-form-item>
          </el-col>
        </el-row>

        <br/>
        <el-row>
          <el-col :span="24">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              试验条件
            </span>
            <span style="margin-left: 30px">
              备注：描述影响检验结果的主要条件。
            </span>
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportConditionVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="measuredResult" label="测定结果">
              <el-input type="text" placeholder="请输入测定结果" v-model="item.measuredResult"/>
            </el-form-item>
          </el-col>
          <el-col :offset="10" :span="4">
            <el-form-item>
              <el-button type="primary" v-if="reportForm.reportConditionVo.length === index + 1" circle
                         icon="el-icon-plus" @click="addItem(reportForm.reportConditionVo)"></el-button>
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportConditionVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <br/>
        <el-row>
          <el-col :span="24">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              样品一致性检查结果
            </span>
            <div style="margin-left: 30px">
              <br/>（1）单项判断合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检查结果、单项判断栏中填“/”，并在备注中说明。
            </div>
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportCheckResultVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="designValue" label="设计值">
              <el-input type="text" placeholder="请输入设计值" v-model="item.designValue"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="limitedField" label="限制范围">
              <el-input type="text" placeholder="请输入限制范围" v-model="item.limitedField"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResult" label="检查结果">
              <el-input type="text" placeholder="请输入检查结果" v-model="item.checkResult"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="10" :span="4">
            <el-form-item>
              <el-button type="primary" v-if="reportForm.reportCheckResultVo.length === index + 1" circle
                         icon="el-icon-plus" @click="addItem(reportForm.reportCheckResultVo)"></el-button>
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportCheckResultVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <br/>
        <el-row>
          <el-col :span="24">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              涵盖机型（或同单元机型）样品一致性检查结果
            </span>
            <div style="margin-left: 30px">
              <br/>（1）单项判断合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检查结果、单项判断栏中填“/”，并在备注中说明。<br/>
              （3）描述未经确认的涵盖机型（或同单元机型）技术规格设计值获取方式。
            </div>
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportSampleSonsResultsVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="designValue" label="设计值">
              <el-input type="text" placeholder="请输入设计值" v-model="item.designValue"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="limitedField" label="限制范围">
              <el-input type="text" placeholder="请输入限制范围" v-model="item.limitedField"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResult" label="检查结果">
              <el-input type="text" placeholder="请输入检查结果" v-model="item.checkResult"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="10" :span="4">
            <el-form-item>
              <el-button type="primary" v-if="reportForm.reportSampleSonsResultsVo.length === index + 1" circle
                         icon="el-icon-plus" @click="addItem(reportForm.reportSampleSonsResultsVo)"></el-button>
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportSampleSonsResultsVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <br/>
        <el-row>
          <el-col :span="24">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              样品安全性检验结果
            </span>
            <div style="margin-left: 30px">
              <br/>
              （1）单项判定合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检查结果、单项判定栏中填“/”，并在备注中说明；<br/>
              （3）采信具有资质的检验检测机构出具的报告，不应体现采信项目的数据结果，可在采信项目的“检验结果”“单项判定”栏中划“/”，并在备注中注明采信项目的来源，如：采信报告的编号、名称及检验检测机构名称等。
            </div>
          </el-col>
          <el-col :span="18">
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportSampleSafetyResultsVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="qualifiedIndicator" label="合格指标">
              <el-input type="text" placeholder="请输入合格指标" v-model="item.qualifiedIndicator"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResult" label="检验结果">
              <el-input type="text" placeholder="请输入检查结果" v-model="item.checkResult"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="20" :span="4">
            <el-form-item>
              <el-button type="primary" v-if="reportForm.reportSampleSafetyResultsVo.length === index + 1" circle
                         icon="el-icon-plus" @click="addItem(reportForm.reportSampleSafetyResultsVo)"></el-button>
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportSampleSafetyResultsVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              涵盖机型（或同单元机型）样品安全性检验结果（若有）
            </span>
            <div style="margin-left: 30px">
              <br/>
              （1）单项判定合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检验结果、单项判定栏中填“/”，并在备注中说明。<br/>
              （3）采信具有资质的检验检测机构出具的报告，不应体现采信项目的数据结果，可在采信项目的“检验结果”“单项判定”栏中划“/”，并在备注中注明采信项目的来源，如：采信报告的编号、名称及检验检测机构名称等。
            </div>
          </el-col>
          <el-col :span="18">
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportConsResultsVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="qualifiedIndicator" label="合格指标">
              <el-input type="text" placeholder="请输入合格指标" v-model="item.qualifiedIndicator"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResult" label="检验结果">
              <el-input type="text" placeholder="请输入检查结果" v-model="item.checkResult"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="20" :span="4">
            <el-form-item>
              <el-button type="primary" v-if="reportForm.reportConsResultsVo.length === index + 1" circle
                         icon="el-icon-plus" @click="addItem(reportForm.reportConsResultsVo)"></el-button>
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportConsResultsVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              样品适用性检验结果
            </span>
            <div style="margin-left: 30px">
              <br/>
              （1）单项判定合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检验结果、单项判定栏中填“/”，并在备注中说明。<br/>
              （3）采信具有资质的检验检测机构出具的报告，不应体现采信项目的数据结果，可在采信项目的“检验结果”“单项判定”栏中划“/”，并在备注中注明采信项目的来源，如：采信报告的编号、名称及检验检测机构名称等。
            </div>
          </el-col>
          <el-col :span="18">
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportSampleSuitResultsVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="qualifiedIndicator" label="合格指标">
              <el-input type="text" placeholder="请输入合格指标" v-model="item.qualifiedIndicator"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResult" label="检验结果">
              <el-input type="text" placeholder="请输入检查结果" v-model="item.checkResult"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="20" :span="4">
            <el-form-item>
              <el-button type="primary" v-if="reportForm.reportSampleSuitResultsVo.length === index + 1" circle
                         icon="el-icon-plus" @click="addItem(reportForm.reportSampleSuitResultsVo)"></el-button>
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportSampleSuitResultsVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              涵盖机型（或同单元机型）样品适用性检验结果（若有）
            </span>
            <div style="margin-left: 30px">
              <br/>
              （1）单项判定合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检验结果、单项判定栏中填“/”，并在备注中说明。<br/>
              （3）采信具有资质的检验检测机构出具的报告，不应体现采信项目的数据结果，可在采信项目的“检验结果”“单项判定”栏中划“/”，并在备注中注明采信项目的来源，如：采信报告的编号、名称及检验检测机构名称等。
            </div>
          </el-col>
          <el-col :span="18">
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportSampleConsSuitResultsVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="qualifiedIndicator" label="合格指标">
              <el-input type="text" placeholder="请输入合格指标" v-model="item.qualifiedIndicator"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResult" label="检验结果">
              <el-input type="text" placeholder="请输入检查结果" v-model="item.checkResult"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="20" :span="4">
            <el-form-item>
              <el-button type="primary" v-if="reportForm.reportSampleConsSuitResultsVo.length === index + 1" circle
                         icon="el-icon-plus" @click="addItem(reportForm.reportSampleConsSuitResultsVo)"></el-button>
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportSampleConsSuitResultsVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              样品可靠性检验结果
            </span>
            <div style="margin-left: 30px">
              <br/>
              （1）单项判定合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检验结果、单项判定栏中填“/”，并在备注中说明。<br/>
              （3）采信具有资质的检验检测机构出具的报告，不应体现采信项目的数据结果，可在采信项目的“检验结果”“单项判定”栏中划“/”，并在备注中注明采信项目的来源，如：采信报告的编号、名称及检验检测机构名称等。<br/>
              （4）样机为1台时，填写“样机1”栏，在“样机2”栏填“/”，并在备注中注明大纲规定检验样机为1台。
            </div>
          </el-col>
          <el-col :span="18">
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportReliabilityResultVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="qualifiedIndicator" label="合格指标">
              <el-input type="text" placeholder="请输入合格指标" v-model="item.qualifiedIndicator"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResulto" label="样机1">
              <el-input type="text" placeholder="请输入检查结果（样机1）" v-model="item.checkResulto"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResultt" label="样机2">
              <el-input type="text" placeholder="请输入检查结果（样机2）" v-model="item.checkResultt"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="20" :span="4">
            <el-form-item>
              <el-button type="primary" v-if="reportForm.reportReliabilityResultVo.length === index + 1" circle
                         icon="el-icon-plus" @click="addItem(reportForm.reportReliabilityResultVo)"></el-button>
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportReliabilityResultVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              涵盖机型（或同单元机型）样品可靠性检验结果
            </span>
            <div style="margin-left: 30px">
              <br/>
              （1）单项判定合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检验结果、单项判定栏中填“/”，并在备注中说明。<br/>
              （3）采信具有资质的检验检测机构出具的报告，不应体现采信项目的数据结果，可在采信项目的“检验结果”“单项判定”栏中划“/”，并在备注中注明采信项目的来源，如：采信报告的编号、名称及检验检测机构名称等。<br/>
              （4）样机为1台时，填写“样机1”栏，在“样机2”栏填“/”，并在备注中注明大纲规定检验样机为1台。
            </div>
          </el-col>
          <el-col :span="18">
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportReliabilityConsResultVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="qualifiedIndicator" label="合格指标">
              <el-input type="text" placeholder="请输入合格指标" v-model="item.qualifiedIndicator"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResulto" label="样机1">
              <el-input type="text" placeholder="请输入检查结果（样机1）" v-model="item.checkResulto"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResultt" label="样机2">
              <el-input type="text" placeholder="请输入检查结果（样机2）" v-model="item.checkResultt"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="20" :span="4">
            <el-form-item>
              <el-button type="primary" v-if="reportForm.reportReliabilityConsResultVo.length === index + 1" circle
                         icon="el-icon-plus" @click="addItem(reportForm.reportReliabilityConsResultVo)"></el-button>
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportReliabilityConsResultVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item prop="reportWriter" label="报告编写人">
              <el-input type="text" placeholder="请输入报告编写人" v-model="reportForm.reportWriter"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="reportWriter" label="报告编写日期">
              <el-date-picker
                  v-model="reportForm.reportDate"
                  type="date"
                  format="yyyy-MM-dd"
                  placeholder="选择报告编写日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <!--        <el-form-item prop="description" label="备注">-->
        <!--          <el-input type="textarea" placeholder="请输入备注" v-model="reportForm.description"/>-->
        <!--        </el-form-item>-->
        <el-form-item>
          <el-button type="primary" @click="submit">保存</el-button>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogShow = false">关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import {httpBaseUrl} from "../util/globa";

export default {
  name: "Admin",
  data() {
    return {
      dialogShow: false,
      reportForm: {
        reportConditionVo: [{}],
        reportCheckResultVo: [{}],
        reportSampleSonsResultsVo: [{}],
        reportSampleConsSuitResultsVo:[{}],
        reportSampleSafetyResultsVo: [{}],
        reportConsResultsVo: [{}],
        reportSampleSuitResultsVo: [{}],
        reportReliabilityResultVo: [{}],
        reportReliabilityConsResultVo: [{}]
      },
      data: [],
      pageNo: 1,
      pageSize: 10,
      total: 0,
      rules: {
        adName: [
          {
            required: true,
            type: 'string',
            message: '用户姓名不能为空',
            trigger: 'blur'
          }
        ],
        adUsername: [
          {
            required: true,
            type: 'string',
            message: '用户名不能为空',
            trigger: 'blur'
          },
          {
            min: 3,
            max: 30,
            message: '用户名长度在3-30位之间',
            trigger: 'blur'
          },
          {
            pattern: /^[0-9A-Za-z_]{3,30}$/,
            message: '用户名只能包含数字、字母、下划线',
            trigger: 'blur'
          },
          // {
          //   validator: (rule, val, cb) => {
          //     let url = `admin/repeat?username=${val}`
          //     if (this.reportForm.id) url += `&id=${this.reportForm.id}`
          //     this.$http.get(url).then(res => {
          //       if (res.code === 200) {
          //         if (res.data) {
          //           return cb(new Error('用户名已存在！'))
          //         }
          //         cb()
          //       }
          //     })
          //   },
          //   trigger: 'blur'
          // }
        ],
        adPassword: [
          {
            required: false,
            type: 'string',
            trigger: 'blur'
          },
          {
            min: 6,
            max: 30,
            message: '密码长度在6-30位之间',
            trigger: 'blur'
          },
          {
            pattern: /^[a-zA-Z0-9-*/+.~!@#$%^&*()]{6,30}$/,
            message: '密码只能包含数字、字母、特殊字符',
            trigger: 'blur'
          }
        ],
        adPhone: [
          {
            required: true,
            type: 'string',
            message: '电话不能为空',
            trigger: 'blur'
          },
          {
            pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
            message: '电话号码格式不正确',
            trigger: 'blur'
          }
        ],
        description: [
          {
            min: 0,
            max: 800,
            message: '备注长度在3-800位之间',
            trigger: 'blur'
          }
        ]
      },
      baseUrl: httpBaseUrl
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    handleAvatarSuccess(res, file) {
      console.log('======================================');
      console.log(res);
      this.imageUrl = URL.createObjectURL(file.raw);
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg';
      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!');
      }
      return isJPG;
    },
    getToken() {
      return `Bearer ${sessionStorage.getItem('token')}`;
    },
    addItem(array) {
      array.push({});
    },
    delItem(array, index) {
      array.splice(index, 1);
    },
    getData() {
      this.search.page = this.pageNo;
      this.search.limit = this.pageSize;
      this.$http.post(`/reportApproval/admin/list`, this.search).then(res => {
        if (res.code === 0) {
          this.pageSize = res.page.pageSize
          this.pageNo = res.page.currPage
          this.total = res.page.totalCount
          this.data = res.page.list
        }
      })
    },
    sizeChange(val) {
      this.pageNo = 1;
      this.pageSize = val;
      this.getData();
    },
    currentChange(val) {
      this.pageNo = val;
      this.getData();
    },
    searchClick() {
      this.pageNo = 1;
      this.getData()
    },
    resetReportForm() {
      this.reportForm = {
        reportConditionVo: [{}],
        reportCheckResultVo: [{}],
        reportSampleSonsResultsVo: [{}],
        reportSampleSafetyResultsVo: [{}],
        reportConsResultsVo: [{}],
        reportSampleSuitResultsVo: [{}],
        reportReliabilityResultVo: [{}],
        reportReliabilityConsResultVo: [{}]
      }
    },
    dialogClose() {
      this.resetForm();
      this.$refs['form'].clearValidate()
    },
    submit() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          if (this.reportForm.adId) {
            this.reportForm.adUpdated = null;
            this.reportForm.adCreated = null;
            this.$http.post(`/reportApproval/admin/update`, this.reportForm).then(res => {
              if (res.code === 0) {
                this.$Message.success(res.msg)
                this.getData()
                this.dialogShow = false
              }
            })
          } else {
            this.$http.post(`/reportApproval/admin/save`, this.reportForm).then(res => {
              if (res.code === 0) {
                this.$Message.success(res.msg)
                this.getData()
                this.dialogShow = false
              }
            })
          }
        }
      });
    },
    del(id) {
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        console.log(id)
        this.$http.post(`/reportApproval/admin/delete`, [id]).then(res => {
          if (res.code === 0) {
            this.getData()
            this.$Message.success(res.msg)
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    }
  }
}
</script>

<style scoped>

</style>
